package com.niit.dao

import com.niit.bean.AnswerWithRecommendations
import com.niit.utils.SparkUtils
import org.apache.spark.sql.Dataset

import java.util.Properties

/**
 * Date:2024/5/30
 * Author：Ys
 * Description:
 */
class EDUBatchDao {
    private val spark = SparkUtils.takeSpark()
    import spark.implicits._
    import org.apache.spark.sql.functions._

    def getEDUData():Dataset[AnswerWithRecommendations]={

        val props = new Properties()
        props.setProperty("user","root")
        props.setProperty("password","Niit@123")
        val answerData: Dataset[AnswerWithRecommendations] =
            spark.read.jdbc("jdbc:mysql://node1:3306/BD2?useUnicode=true&characterEncoding=utf8"
            , "edu", props).as[AnswerWithRecommendations]

        answerData
    }

}
